home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
EnigmA Amiga Run 1997 April
/
EnigmA AMIGA RUN 17 (1997)(G.R. Edizioni)(IT)[!][issue 1997-04][EAR-CD].iso
/
EARCD
/
comm
/
bbs
/
Hydra11s.lha
/
HBBS
/
Source
/
Doors_System
/
AwaitConnect
/
Main.c
< prev
next >
Wrap
C/C++ Source or Header
|
1996-10-31
|
7KB
|
255 lines
/*
Await Connect Door for HBBS (C) 1995 Hydra/LSD
function of the "AWAIT" door
============================
- display "Await" screen
- check for incoming calls
- set N_ND->ConnectBaud accordingly.
- check for local logins
- set N_ND->ConnectBaud to "LOCAL"
- check for shutdown requests
- set N_ND->LoginType correctly
todo
====
Make await door aware of when the user opens/closes the watch window
and display the "Await" Special Screen when they open the window.
*/
#include <exec/types.h>
#include <exec/memory.h>
#include <dos/dos.h> // JUST so we can call SetProgramName()
#include <clib/dos_protos.h>
#include <clib/exec_protos.h>
#include <clib/alib_protos.h>
#include <stdlib.h>
#include <string.h>
#include <stdio.h>
#include <ctype.h>
#include <time.h>
#ifdef __SASC
int CXBRK(void) { return(0); }
int _CXBRK(void) { return(0); }
void chkabort(void) {}
#endif
#include <HBBS/ANSI_Codes.h>
#include <HBBS/Defines.h>
#include <HBBS/types.h>
#include <HBBS/structures.h>
#include <HBBS/hbbscommon_protos.h>
#include <HBBS/hbbscommon_pragmas.h>
#include <HBBS/Hbbsnode_protos.h>
#include <HBBS/Hbbsnode_pragmas.h>
#include <HBBS/release.h>
char *versionstr="$VER: AwaitConnect "RELEASE_STR;
extern struct Library *DOSBase;
extern struct Library *SysBase;
struct Library *HBBSCommonBase=NULL;
struct Library *HBBSNodeBase=NULL;
struct BBSGlobalData *BBSGlobal=NULL;
struct NodeData *N_ND=NULL;
int N_NodeNum=-1;
UBYTE *str_CRLF="\n\r\0";
static VOID cleanup(ULONG num)
{
if (HBBSNodeBase)
{
HBBS_CleanUpDoor();
CloseLibrary (HBBSNodeBase);
}
if (HBBSCommonBase)
{
HBBS_CleanUpCommon();
CloseLibrary (HBBSCommonBase);
}
if (num) printf("Door Error = %d\n",num);
exit(0);
}
static VOID init(char *name)
{
if(!(HBBSCommonBase = OpenLibrary("HBBSCommon.library",0)))
{
cleanup(1);
}
if (!(HBBS_InitCommon()))
{
cleanup(2);
}
if(!(HBBSNodeBase = OpenLibrary("HBBSNode.library",0)))
{
cleanup(3);
}
if (!(HBBS_InitDoor(N_NodeNum,name)))
{
cleanup(4);
}
SetProgramName(name);
}
V_BOOL CheckModemConnectStr( void )
{
V_BOOL retval=FALSE;
struct Node *nd;
short tmpval1,tmpval2;
for (nd = N_ND->NodeDevice.RelaxedConnectStr->lh_Head ; nd->ln_Succ ; nd = nd->ln_Succ)
{
if (nd->ln_Name)
{
if (iposition(nd->ln_Name,N_ND->CurrentLine)>=0)
{
retval=TRUE;
// ok, get the baud rate from the connect string!
tmpval1=iposition(" ",N_ND->CurrentLine);
tmpval2=iposition("/",N_ND->CurrentLine)-1; // miss out the "/"
if (tmpval1 >= 0)
{
tmpval1++; // miss out the " "
if (tmpval2 <0)
{
tmpval2=strlen(N_ND->CurrentLine)-1;
}
if (tmpval2>tmpval1)
{
strftcpy(N_ND->ConnectBaud,N_ND->CurrentLine,tmpval1,tmpval2);
}
}
else // can't determine connect speed, so set to 28800 so doors don't get confused by a blank string!
{
strcpy(N_ND->ConnectBaud,"28800");
}
}
}
}
return(retval);
}
void CheckModemIncomingStr( void )
{
if (N_ND->NodeDevice.Incoming!=NULL && iposition(N_ND->NodeDevice.Incoming,N_ND->CurrentLine)>=0)
{
DOOR_SysopText("Incoming Call...\r\n");
}
}
void DisplayAwaitScreen( void )
{
if (!DOOR_DisplaySpecialScreen("Await")) // Display Await Screen..
{
DOOR_SysopText(ANSI_RESET ANSI_FG_CYAN
ANSI_FG_PURPLE " [" ANSI_FG_WHITE "F1" ANSI_FG_PURPLE "] " ANSI_FG_WHITE " - " ANSI_FG_GREEN "Local Login\n\r"
ANSI_FG_PURPLE " [" ANSI_FG_WHITE "F2" ANSI_FG_PURPLE "] " ANSI_FG_WHITE " - " ANSI_FG_GREEN "Initialise Modem\n\r"
ANSI_FG_PURPLE " [" ANSI_FG_WHITE "F3" ANSI_FG_PURPLE "] " ANSI_FG_WHITE " - " ANSI_FG_GREEN "Answer Modem Now\n\r"
ANSI_FG_PURPLE " [" ANSI_FG_WHITE "F5" ANSI_FG_PURPLE "] " ANSI_FG_WHITE " - " ANSI_FG_GREEN "Toggle modem Debug\n\r"
ANSI_FG_PURPLE " [" ANSI_FG_WHITE "F7" ANSI_FG_PURPLE "] " ANSI_FG_WHITE " - " ANSI_FG_GREEN "Close Watch Window/Screen\n\r"
ANSI_FG_PURPLE " [" ANSI_FG_WHITE "F8" ANSI_FG_PURPLE "] " ANSI_FG_WHITE " - " ANSI_FG_GREEN "Toggle Watch between Screen or Window\n\r"
ANSI_FG_PURPLE " [" ANSI_FG_WHITE "F9" ANSI_FG_PURPLE "] " ANSI_FG_WHITE " - " ANSI_FG_GREEN "Terminal Door\n\r"
ANSI_FG_PURPLE " [" ANSI_FG_WHITE "F10" ANSI_FG_PURPLE "]" ANSI_FG_WHITE " - " ANSI_FG_GREEN "Shutdown This Node\n\r\r\n"
"Awaiting Connect ....\r\n");
}
}
void DoorMain( void )
{
ULONG getlinestatus;
DisplayAwaitScreen();
do
{
N_ND->LoginType=LOGIN_NONE;
getlinestatus=DOOR_GetLine(GL_NONE,'\0',0,0,NULL);
DOOR_SysopText(N_ND->CurrentLine);
DOOR_SysopText(str_CRLF);
switch (getlinestatus)
{
case IN_LOGIN:
N_ND->LoginType=LOGIN_LOCAL;
break;
case IN_IMMEDIATE:
DOOR_WriteSerText(N_ND->NodeDevice.ImmediateAnswer);
DOOR_WriteSerText("\n\r");
break;
case IN_TERMINAL:
DOOR_SysopText("This will run a terminal door using the bbs's setup\n\r"
"It'll save you having to close the node down to run\n\r"
"A comms program!\n\r");
break;
case IN_GOTLINE:
if (!N_ND->NodeDevice.NullModemCable)
{
CheckModemIncomingStr();
if (CheckModemConnectStr()) N_ND->LoginType=LOGIN_REMOTE;
}
else
{
DOOR_WriteSerText("CONNECT\r\n");
strcpy(N_ND->ConnectBaud,"LOCAL");
N_ND->LoginType=LOGIN_REMOTE;
}
break;
case IN_SHUTDOWN:
N_ND->RequestShutdown=TRUE;
break;
case IN_DISPLAYAWAIT:
DisplayAwaitScreen();
break;
case IN_DIALOUT:
DOOR_SysopText("Enter Number > ");
N_ND->LoginType=LOGIN_LOCAL;
if (IN_GOTLINE==DOOR_GetLine(GL_SYSOP|GL_EDIT|GL_DISPLAY,'\0',0,0,NULL))
{
if (N_ND->CurrentLine[0])
{
DOOR_WriteSerText("ATDT");
DOOR_WriteSerText(N_ND->CurrentLine);
DOOR_WriteSerText("\r\n");
}
}
N_ND->LoginType=LOGIN_NONE;
break;
}
} while (N_ND->RequestShutdown==FALSE && N_ND->LoginType==LOGIN_NONE);
}
int main(int argc,char *argv[])
{
if (sscanf(argv[1],"%d",&N_NodeNum)==0)
{
printf("Invalid/No Paramaters for door!\n");
exit (20);
}
init("Awaiting Connect");
if (BBSGlobal=HBBS_GimmeBBS())
{
if (N_ND=HBBS_NodeDataPtr(N_NodeNum)) // this should not fail in normal circumstances..
{
DoorMain();
}
}
cleanup(0);
}